<script>
import { dateFormat, jsonParseItem, showToast } from '@/utils';

export default {
	globalData: {
		serverImg: import.meta.env.VITE_serverImg,
		webUrl: import.meta.env.VITE_webview,
    networkConnected: true,
    envTag: import.meta.env.VITE_ENV,
    isAppLaunch: false,
    isLoveCarMoveBox: false,
	},
  onLaunch(options) {
    this.globalData.isAppLaunch = true;
    this.globalData.isLoveCarMoveBox = true;
	},
	onShow() {
		const that = this;
		uni.getNetworkType({
			success(res) {
				that.globalData.networkConnected = res.networkType != 'none';
			}
		})
	},
	onHide() {
	},
	onError(err) {
		console.error(err)
	},
	onUnhandledRejection(err) {
	},
	onPageNotFound() {
	},
	onThemeChange() {

	},
	onLastPageBackPress() {

	},
	onExit() {
		uni.stopBluetoothDevicesDiscovery();
    uni.offNetworkStatusChange(this.showNoNetworkTip)
	},
	methods: {
    showNoNetworkTip(networkStatus) {
      if (!networkStatus.isConnected) {
        this.globalData.networkConnected = false;
        showToast("网络异常")
      } else {
        this.globalData.networkConnected = true;
      }
    },
		dateFormat,
		jsonParseItem,
		showToast
	}
}
</script>

<style lang="scss">
/*每个页面公共css */
@use '@/styles/app.scss';

// 设置整个项目的背景色
page {
	width: 100%;
	background-color: #f7f7f7;
	flex-direction: column;
  position: relative !important;
  top: 0px !important;
}
@-webkit-keyframes shadow-preload {
	0% {
		background:none!important;
	}
	100% {
		background:none!important;
	}
}
@keyframes shadowpreload {
	0% {
		background:none!important;
	}
	100% {
		background:none!important;
	}
}
</style>
